<template>
  <div class="word1-container">
    <div class="title">检测单位法定代表人声明</div>
    <div class="word-main">
      <div class="word-content1">
        <div class="content-line">
          <span>申请单位：</span>
          <div style="width: 300px;height:auto;text-align:left" class="input-line">{{ formData.sqdw }}</div>
          <!-- <input
            v-model="formData.sqdw"
            type="text"
            class="input-line"
            style="width: 300px"
            :disabled="true"
          /> -->
        </div>
        <div class="content-line">
          <div class="line-main">
            <span>申请专业：</span>
<!--            <Aselect-->
<!--              v-model="formData.sqzy"-->
<!--              class="select-line"-->
<!--              style="width: 300px;"-->
<!--              :disabled="disabled"-->
<!--              :options="sqzyOptions"-->
<!--              placeholder=""-->
<!--              @change="checkMajor"-->
<!--            />-->
            <MultiSelect
                v-model="formData.sqzy"
                class="select-line"
                style="width: 300px;"
                :disabled="disabled"
                :options="sqzyOptions"
                placeholder=""
                @change="checkMajor"
            />
            <span class="tips">(乙级)</span>
          </div>
        </div>
        <div class="content-line">
          <span>填表日期：</span>
          <AdatePicker
            v-model="formData.tbrq"
            style="width: 300px"
            class="datepicker-line"
            :clearable="false"
            :disabled="disabled"
            :pickerOptions="pickerOptions()"
            placeholder=""
          />
        </div>
      </div>
      <div class="word-content2">
        <div class="content">
          <!-- &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -->
          <span>本人</span>
          <input
            v-model="formData.appPer"
            type="text"
            class="input-line"
            style="width: 140px"
            :disabled="disabled"
          />
          <span>（法定代表人）</span>
          <input type="text" class="input-line" style="width: 60px" disabled />
          <input
            v-model.trim="formData.fddbrZjh"
            type="text"
            class="input-line"
            style="width: 180px"
            :disabled="fddbrZjhDisabled"
          />
          (身份证号码)郑重声明，本单位填报的《重庆市水利工程质量检测单位乙级资质等级认定申请表》及附件材料全部属实。并与全国水利建设市场监管服务平台上公开的信息一致。如有提供虚假材料以及其他违法行为，本单位和本人愿意接受水行政主管部门及其他有关部门依据有关法律法规给予的处罚。
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import AdatePicker from '@/components/TimePicker/AdatePicker';
import MultiSelect from "@/components/Select/MultiSelect";
import { fieldsValidate } from '@/utils/validate.js';
import businessApi from '@/api/business';
export default {
  props: {
    formData: {
      type: Object,
    },
    disabled: {
      type: Boolean,
      default: false,
    },
  },
  components: { AdatePicker, MultiSelect },
  data() {
    return {};
  },
  computed: {
    fddbrZjhDisabled() {
      return this.disabled;
    },
    sqzyOptions() {
      return businessApi.getApplyMajors(this.$dict('major').list());
    },
    sqzyData() {
      return this.formData.sqzy?.split(',') || [];
    }
  },
  methods: {
    formValidated() {
      const rules = {
        sqzy: [{required: true, text: '请输入申请专业'}],
        tbrq: [{required: true, text: '请输入填表日期'}],
        fddbrZjh: [
          {required: true, text: '请输入身份证号码'},
          {
            pattern: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
            text: '请输入正确格式的身份证号码',
          },
        ],
      };
      return fieldsValidate(this.formData, rules, this);
    },
    pickerOptions() {
      return {
        disabledDate(time) {
          return time.getTime() > Date.now();
        },
      };
    },
    checkMajor(value) {
      businessApi.checkUnitMajor({
        majorType: value
      }).then(res => {
        if (res) {
          this.$message.error('该专业单位已申请，不能重复申请');
          this.formData.sqzy = '';
        }
      })
      this.formData.sqzy = value + '';
    },
  }
};
</script>
<style lang="scss" scoped>
@import '../../../../../../assets/styles/word.scss';
.word1-container {
  text-align: center;
  width: 680px;
  .title {
    font-size: 24px;
    font-weight: bold;
  }
  .word-main {
    margin-top: 16px;
    background: #fff;
    border: 1px solid gray;
    .word-content1 {
      margin: 140px 0px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      .content-line {
        display: flex;
        justify-content: center;
        line-height: 32px;
        align-items: flex-end;
        .line-main {
          position: relative;
          .tips {
            position: absolute;
            right: 0px;
            top: 6px;
            font-size: 16px;
          }
        }
        ::v-deep .datepicker-line {
          input {
            height: 30px;
            line-height: 30px;
            border-radius: 0;
            text-align: left !important;
            border-bottom: 1px solid gray !important;
          }
        }
      }
    }
    .word-content2 {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      justify-content: flex-start;
      padding: 0 20px;
      .title {
        margin-bottom: 30px;
      }
      .content {
        margin-bottom: 80px;
        text-align: left;
        line-height: 30px;
      }
    }
  }
}
</style>
